/**
 * Exports functions to Euclid
 * 
 * @author Jon Ludwig
 *
 */

import Euclid.*;
import java.math.*;
import java.util.*;

public class EuclidExport implements EuclidExporter {
	
	public String[] getExports()
	{
		return new String[] { "divisors" };
	}
	
	public VarType divisors(VarType a)
	{
		if (a instanceof SymbVarType)
			return divisors(((SymbVarType)a).val);
		else if (a instanceof IntVarType)
		{
			StringBuilder s = new StringBuilder();
			ArrayList<BigInteger> divs = Divisors.divisors(((IntVarType)a).val);
			for (BigInteger d : divs)
				s.append(d);
			
			return new StringVarType(s.toString(),
					"\\mathrm{divisors}(" + a.formula + ")");
		}
		else
			return null;
	}

}
